/******************************init****************************/
function queryParkCommodity(page) {
	var parm = $('#queryParkCommodityForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('parkcommodity-query');
	sys_record_parm('parkcommodity',parm);
	sys_loading();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#resultList').html(result);
		}
	});
}
function deleteParkCommodity(code) {
	$.Zebra_Dialog('是否删除',{
		'type': 'question',
		'title': '警告' ,
		'buttons':[
		{caption:'删除',callback:function() {
	    	   var url = create_url('parkcommodity-delete');
			parkCommodity_aidExecute(code, url);
	    }},
	    {caption:'取消',callback:function(){}
	    }]
	});
}

function parkCommodity_aidExecute(code, url) {
	var parm = {'code':code};
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if ('success' == result) {
				sys_msg('操作成功');
				queryParkCommodity();
			} else {
				sys_msg('操作失败');
				queryParkCommodity();
			}
		}
	});
}
/************edit******************/
function saveParkCommodity() {
	var parm = $('#editCommodityShowForm').serialize();
	var url = create_url('parkcommodity-save');
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
		sys_submiting_close();
			if ('success' == result) {
				sys_msg('操作成功!');
				sys_load_handle('parkcommodity');
			}
		}
	});
}

function selectCommodity() {
		var url = create_url('parkcommodity-queryCommodityInit');
		var parm = {};
		$.colorbox({overlayClose:false, href:url, data:parm, close:'[关闭]', width:'750px',height:'500px', open:true});
}

function checkedParkCommodity(){
	var name = $("#name").val();
	var sort = $("#sort").val();
	if(name.length == 0){
		sys_msg('必须选择产品！');
		return
	}
	if(sort.length == 0){
		sys_msg('必须填写产品排行号!');
		return
	}else if(sort <= 0){
		sys_msg('排好序号必须是大于0的整数!');
		return
	}
	saveParkCommodity();
}
/******************************aidinit****************************/
function queryCommodity(page) {
	var parm = $('#queryCommodityForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('parkcommodity-queryCommodityList');
	sys_loading();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#resultList').html(result);
		}
	});
}
function chooseWorkGuideOrgan(code, name, oc) {
	$("#cc").val(code);
	$("#name").val(name);
	$("#oc").val(oc);
	$.fn.colorbox.close();
}

$(".txt_userlist_name").keydown(function(event) {
	if (event.keyCode == '13') {
		queryCommodity();
		return false;
	}
});
/******************************aidbatchinit****************************/
